1 Rmd settings

Sys.setenv(LANG = "en") #English
knitr::opts_chunk$set(echo = TRUE)
rm(list = ls())

path <- getwd()

setwd(path)

# packages
pacman::p_load(tidyverse, plotly,readxl,scales, extrafont,PerformanceAnalytics, GGally, patchwork, ggpubr, DT, estimatr, texreg, modelsummary)

# Font for windows and mac
if (stringr::str_detect(path, pattern="Users")){ 
  
   theme_set(theme_classic(base_size = 10, base_family = "HiraginoSans-W3"))  # For Mac OS

 } else{
  
theme_set(theme_classic(base_size = 10, base_family = "Arial"))        # For Windows

 }

2 Contents

  • WLS regression of suicide on Public assistance (PA) benefits (unemploy_diff2)

3 Read functions/関数の読み込み

  • dynamic_DID_OLS_notrend: dynamic DID with OLS and without prefectre linear trend

  • dynamic_DID_WLS_notrend: dynamic DID with WLS and without prefectre linear trend

  • dynamic_DID_OLS_trend: dynamic DID with OLS and prefectre linear trend

  • dynamic_DID_WLS_trend: dynamic DID with WLS and prefectre linear trend

  • dynamic_onlypost_DID_WLS_trend: dynamic DID only and with WLS and prefectre linear trend, reference periods = all the pre-COVID months

  • _covar8Xcovid_months: with eight covariates interacted with month dummies

source("functions.R")

4 Read data/分析用データの読み込み

df_analysis <- readr::read_csv("output/df_analysis.csv")
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   prefec_kanji = col_character(),
##   prefecture = col_character(),
##   date = col_date(format = ""),
##   prefec = col_character(),
##   prefec_kanji2 = col_character()
## )
## See spec(...) for full column specifications.

5 Main figures in the paper

  • We firstly provide estimations and figures used in the main text.
  • These chunks are copied and pasted from subsequent outcome-based result sections.
  • Actual graphs and tables in the paper are generated and saved in the subsequent chunks, not the chunks in this section. But they are identical.

6 Y=PA recipients/生活保護受給者数

7 Y=PA recipients/生活保護受給者数 with covar

8 Y=PA recipients(YOY)/生活保護受給者数(前年同月差)

8.5 WLS, with trends, post-covid-month dummies, Table C.7 (2)

# DID estimation
estimation_results <- dynamic_onlypost_DID_WLS_trend(dataset = df_analysis, 
                    outcome_var = df_analysis$yoy_persons_receive, 
                    treat_var = df_analysis$unemploy_shock_diff2)

texreg::screenreg(l = estimation_results , include.ci = FALSE, digits=3)
## 1 coefficient  not defined because the design matrix is rank deficient
## 
## ===========================================
##                                Model 1     
## -------------------------------------------
## treat_var:date_2020_02            2.613    
##                                  (1.513)   
## treat_var:date_2020_03            5.137 *  
##                                  (1.970)   
## treat_var:date_2020_04            7.333 ** 
##                                  (2.665)   
## treat_var:date_2020_05           10.014 ** 
##                                  (2.913)   
## treat_var:date_2020_06           14.241 ***
##                                  (3.869)   
## treat_var:date_2020_07           14.301 ** 
##                                  (4.369)   
## treat_var:date_2020_08           14.761 ** 
##                                  (4.760)   
## treat_var:date_2020_09           16.169 ** 
##                                  (5.262)   
## as.factor(id)1:year_month_id     -0.201    
##                                  (0.186)   
## as.factor(id)2:year_month_id     -0.771 ***
##                                  (0.109)   
## as.factor(id)3:year_month_id     -0.671 ***
##                                  (0.123)   
## as.factor(id)4:year_month_id     -0.781 ***
##                                  (0.145)   
## as.factor(id)5:year_month_id     -0.975 ***
##                                  (0.140)   
## as.factor(id)6:year_month_id     -0.719 ***
##                                  (0.133)   
## as.factor(id)7:year_month_id     -1.108 ***
##                                  (0.126)   
## as.factor(id)8:year_month_id     -1.114 ***
##                                  (0.078)   
## as.factor(id)9:year_month_id      0.269 ** 
##                                  (0.082)   
## as.factor(id)10:year_month_id    -0.219 ***
##                                  (0.059)   
## as.factor(id)11:year_month_id    -0.349 *  
##                                  (0.170)   
## as.factor(id)12:year_month_id    -0.703 ***
##                                  (0.163)   
## as.factor(id)13:year_month_id    -0.749 ***
##                                  (0.178)   
## as.factor(id)14:year_month_id    -0.693 ** 
##                                  (0.225)   
## as.factor(id)15:year_month_id    -0.781 ***
##                                  (0.102)   
## as.factor(id)16:year_month_id    -0.201    
##                                  (0.112)   
## as.factor(id)17:year_month_id    -0.055    
##                                  (0.091)   
## as.factor(id)18:year_month_id     0.273 ***
##                                  (0.064)   
## as.factor(id)19:year_month_id    -0.651 ***
##                                  (0.098)   
## as.factor(id)20:year_month_id    -0.130 *  
##                                  (0.062)   
## as.factor(id)21:year_month_id    -0.191 ** 
##                                  (0.071)   
## as.factor(id)22:year_month_id     0.026    
##                                  (0.085)   
## as.factor(id)23:year_month_id     0.181    
##                                  (0.095)   
## as.factor(id)24:year_month_id     0.176    
##                                  (0.097)   
## as.factor(id)25:year_month_id    -0.127    
##                                  (0.089)   
## as.factor(id)26:year_month_id    -0.604 ***
##                                  (0.150)   
## as.factor(id)27:year_month_id    -0.693 ** 
##                                  (0.217)   
## as.factor(id)28:year_month_id    -0.753 ***
##                                  (0.170)   
## as.factor(id)29:year_month_id    -2.080 ***
##                                  (0.196)   
## as.factor(id)30:year_month_id    -1.812 ***
##                                  (0.193)   
## as.factor(id)31:year_month_id    -1.028 ***
##                                  (0.128)   
## as.factor(id)32:year_month_id              
##                                            
## as.factor(id)33:year_month_id    -0.437 ***
##                                  (0.091)   
## as.factor(id)34:year_month_id     0.315 ** 
##                                  (0.099)   
## as.factor(id)35:year_month_id    -0.453 ***
##                                  (0.109)   
## as.factor(id)36:year_month_id    -0.160    
##                                  (0.122)   
## as.factor(id)37:year_month_id    -0.636 ***
##                                  (0.115)   
## as.factor(id)38:year_month_id    -0.417 ***
##                                  (0.107)   
## as.factor(id)39:year_month_id    -0.133    
##                                  (0.089)   
## as.factor(id)40:year_month_id     0.043    
##                                  (0.127)   
## as.factor(id)41:year_month_id    -0.219 ***
##                                  (0.025)   
## as.factor(id)42:year_month_id    -0.548 ***
##                                  (0.089)   
## as.factor(id)43:year_month_id     0.751 ***
##                                  (0.090)   
## as.factor(id)44:year_month_id     0.350 *  
##                                  (0.130)   
## as.factor(id)45:year_month_id     0.082    
##                                  (0.091)   
## as.factor(id)46:year_month_id     0.354 *  
##                                  (0.146)   
## as.factor(id)47:year_month_id    -0.393    
##                                  (0.235)   
## -------------------------------------------
## R^2                               0.961    
## Adj. R^2                          0.958    
## Num. obs.                      1551        
## RMSE                            221.021    
## N Clusters                       47        
## ===========================================
## *** p < 0.001; ** p < 0.01; * p < 0.05
# DID estimates and 90% CI
df_estimates <- DID_coefficients_main(DID_results = estimation_results, 
                                         treat_var = "unemploy_shock_diff2",
                                 estimation_label = "yoy_hogo_persons_WLS_trend")

# Event study graph
graph_yoy_hogo_persons_WLS_trend_onlypost <- event_study_graph(data = df_estimates ,
                                          graph_title = "yoy_hogo_persons_WLS_trend")

ggplotly(graph_yoy_hogo_persons_WLS_trend_onlypost)
estimates_yoy_hogo_persons_WLS_trend_onlypost <- df_estimates #for robustness check

results_yoy_hogo_persons_WLS_trend_onlypost <- estimation_results # for only-post DID table

9 Y=PA recipients(YOY)/生活保護受給者数(前年同月差)with covar

9.5 WLS, with trends, post-covid-month dummies, Table C.8 (2)

# DID estimation
estimation_results <- dynamic_onlypost_DID_WLS_trend_covar8Xcovid_months(dataset = df_analysis, 
                    outcome_var = df_analysis$yoy_persons_receive, 
                    treat_var = df_analysis$unemploy_shock_diff2)

texreg::screenreg(l = estimation_results , include.ci = FALSE, digits=3)
## 1 coefficient  not defined because the design matrix is rank deficient
## 
## ====================================================================
##                                                         Model 1     
## --------------------------------------------------------------------
## treat_var:date_2020_02                                     1.156    
##                                                           (2.596)   
## treat_var:date_2020_03                                     3.312    
##                                                           (3.078)   
## treat_var:date_2020_04                                     5.302    
##                                                           (4.374)   
## treat_var:date_2020_05                                     4.872    
##                                                           (4.639)   
## treat_var:date_2020_06                                     7.395    
##                                                           (5.526)   
## treat_var:date_2020_07                                     9.683    
##                                                           (5.718)   
## treat_var:date_2020_08                                     8.889    
##                                                           (6.118)   
## treat_var:date_2020_09                                    12.288    
##                                                           (6.300)   
## date_2020_02:google_mobility_index_2020may                 0.145    
##                                                           (0.602)   
## date_2020_03:google_mobility_index_2020may                 0.055    
##                                                           (0.744)   
## date_2020_04:google_mobility_index_2020may                -0.100    
##                                                           (0.904)   
## date_2020_05:google_mobility_index_2020may                -0.545    
##                                                           (0.907)   
## date_2020_06:google_mobility_index_2020may                -1.013    
##                                                           (1.081)   
## date_2020_07:google_mobility_index_2020may                -1.260    
##                                                           (1.096)   
## date_2020_08:google_mobility_index_2020may                -1.768    
##                                                           (1.128)   
## date_2020_09:google_mobility_index_2020may                -2.016    
##                                                           (1.224)   
## date_2020_02:infection_rate_cumulative2020jun              0.455    
##                                                           (0.322)   
## date_2020_03:infection_rate_cumulative2020jun              0.276    
##                                                           (0.405)   
## date_2020_04:infection_rate_cumulative2020jun              0.369    
##                                                           (0.430)   
## date_2020_05:infection_rate_cumulative2020jun              0.113    
##                                                           (0.537)   
## date_2020_06:infection_rate_cumulative2020jun             -0.061    
##                                                           (0.586)   
## date_2020_07:infection_rate_cumulative2020jun             -0.290    
##                                                           (0.615)   
## date_2020_08:infection_rate_cumulative2020jun             -0.493    
##                                                           (0.656)   
## date_2020_09:infection_rate_cumulative2020jun             -0.652    
##                                                           (0.628)   
## date_2020_02:death_rate_cumulative2020jun                 -4.090    
##                                                           (3.341)   
## date_2020_03:death_rate_cumulative2020jun                 -3.024    
##                                                           (4.309)   
## date_2020_04:death_rate_cumulative2020jun                 -3.796    
##                                                           (4.572)   
## date_2020_05:death_rate_cumulative2020jun                 -2.399    
##                                                           (5.624)   
## date_2020_06:death_rate_cumulative2020jun                 -0.807    
##                                                           (6.321)   
## date_2020_07:death_rate_cumulative2020jun                  3.007    
##                                                           (6.694)   
## date_2020_08:death_rate_cumulative2020jun                  4.293    
##                                                           (7.042)   
## date_2020_09:death_rate_cumulative2020jun                  6.049    
##                                                           (6.888)   
## date_2020_02:Population_per_1_km_2_of_inhabitable_area    -0.000    
##                                                           (0.001)   
## date_2020_03:Population_per_1_km_2_of_inhabitable_area     0.000    
##                                                           (0.001)   
## date_2020_04:Population_per_1_km_2_of_inhabitable_area    -0.001    
##                                                           (0.001)   
## date_2020_05:Population_per_1_km_2_of_inhabitable_area    -0.000    
##                                                           (0.001)   
## date_2020_06:Population_per_1_km_2_of_inhabitable_area     0.000    
##                                                           (0.001)   
## date_2020_07:Population_per_1_km_2_of_inhabitable_area     0.001    
##                                                           (0.001)   
## date_2020_08:Population_per_1_km_2_of_inhabitable_area     0.001    
##                                                           (0.001)   
## date_2020_09:Population_per_1_km_2_of_inhabitable_area     0.001    
##                                                           (0.001)   
## date_2020_02:Secondary_industry_ratio                     86.794 *  
##                                                          (40.352)   
## date_2020_03:Secondary_industry_ratio                     95.671    
##                                                          (48.602)   
## date_2020_04:Secondary_industry_ratio                    108.190    
##                                                          (57.794)   
## date_2020_05:Secondary_industry_ratio                    129.267 *  
##                                                          (58.619)   
## date_2020_06:Secondary_industry_ratio                    179.775 *  
##                                                          (67.682)   
## date_2020_07:Secondary_industry_ratio                    205.606 ** 
##                                                          (70.335)   
## date_2020_08:Secondary_industry_ratio                    235.359 ** 
##                                                          (71.659)   
## date_2020_09:Secondary_industry_ratio                    266.150 ** 
##                                                          (82.577)   
## date_2020_02:Tertiary_industry_ratio                      61.656    
##                                                          (52.970)   
## date_2020_03:Tertiary_industry_ratio                      70.341    
##                                                          (70.439)   
## date_2020_04:Tertiary_industry_ratio                      60.358    
##                                                          (74.751)   
## date_2020_05:Tertiary_industry_ratio                     104.078    
##                                                          (85.829)   
## date_2020_06:Tertiary_industry_ratio                     130.846    
##                                                          (97.156)   
## date_2020_07:Tertiary_industry_ratio                     100.597    
##                                                          (98.740)   
## date_2020_08:Tertiary_industry_ratio                     127.149    
##                                                         (100.693)   
## date_2020_09:Tertiary_industry_ratio                     122.783    
##                                                          (99.628)   
## date_2020_02:Total_population                              0.005    
##                                                           (0.004)   
## date_2020_03:Total_population                              0.007    
##                                                           (0.006)   
## date_2020_04:Total_population                              0.010    
##                                                           (0.007)   
## date_2020_05:Total_population                              0.007    
##                                                           (0.007)   
## date_2020_06:Total_population                              0.012    
##                                                           (0.009)   
## date_2020_07:Total_population                              0.011    
##                                                           (0.010)   
## date_2020_08:Total_population                              0.012    
##                                                           (0.009)   
## date_2020_09:Total_population                              0.015    
##                                                           (0.011)   
## date_2020_02:Ratio_of_aged_population                      0.011    
##                                                           (0.273)   
## date_2020_03:Ratio_of_aged_population                      0.108    
##                                                           (0.342)   
## date_2020_04:Ratio_of_aged_population                      0.024    
##                                                           (0.413)   
## date_2020_05:Ratio_of_aged_population                     -0.060    
##                                                           (0.429)   
## date_2020_06:Ratio_of_aged_population                      0.213    
##                                                           (0.484)   
## date_2020_07:Ratio_of_aged_population                      0.384    
##                                                           (0.495)   
## date_2020_08:Ratio_of_aged_population                      0.609    
##                                                           (0.507)   
## date_2020_09:Ratio_of_aged_population                      0.847    
##                                                           (0.560)   
## as.factor(id)1:year_month_id                               0.715 ***
##                                                           (0.175)   
## as.factor(id)2:year_month_id                               0.430 ***
##                                                           (0.101)   
## as.factor(id)3:year_month_id                               0.285 ***
##                                                           (0.070)   
## as.factor(id)4:year_month_id                              -0.102    
##                                                           (0.165)   
## as.factor(id)5:year_month_id                              -0.040    
##                                                           (0.143)   
## as.factor(id)6:year_month_id                               0.077    
##                                                           (0.178)   
## as.factor(id)7:year_month_id                              -0.431 *  
##                                                           (0.164)   
## as.factor(id)8:year_month_id                              -0.585 ***
##                                                           (0.148)   
## as.factor(id)9:year_month_id                               0.789 ***
##                                                           (0.160)   
## as.factor(id)10:year_month_id                              0.184    
##                                                           (0.193)   
## as.factor(id)11:year_month_id                              0.193    
##                                                           (0.156)   
## as.factor(id)12:year_month_id                             -0.147    
##                                                           (0.224)   
## as.factor(id)13:year_month_id                             -0.393 *  
##                                                           (0.180)   
## as.factor(id)14:year_month_id                             -0.291    
##                                                           (0.170)   
## as.factor(id)15:year_month_id                             -0.200    
##                                                           (0.146)   
## as.factor(id)16:year_month_id                              0.148    
##                                                           (0.251)   
## as.factor(id)17:year_month_id                              0.435    
##                                                           (0.234)   
## as.factor(id)18:year_month_id                              0.782 ***
##                                                           (0.195)   
## as.factor(id)19:year_month_id                             -0.103    
##                                                           (0.226)   
## as.factor(id)20:year_month_id                              0.383    
##                                                           (0.224)   
## as.factor(id)21:year_month_id                              0.126    
##                                                           (0.206)   
## as.factor(id)22:year_month_id                              0.297    
##                                                           (0.214)   
## as.factor(id)23:year_month_id                              0.393 *  
##                                                           (0.187)   
## as.factor(id)24:year_month_id                              0.596 ** 
##                                                           (0.182)   
## as.factor(id)25:year_month_id                              0.319    
##                                                           (0.196)   
## as.factor(id)26:year_month_id                              0.071    
##                                                           (0.221)   
## as.factor(id)27:year_month_id                             -0.206    
##                                                           (0.162)   
## as.factor(id)28:year_month_id                             -0.292    
##                                                           (0.193)   
## as.factor(id)29:year_month_id                             -1.357 ***
##                                                           (0.190)   
## as.factor(id)30:year_month_id                             -0.839 ***
##                                                           (0.150)   
## as.factor(id)31:year_month_id                                       
##                                                                     
## as.factor(id)32:year_month_id                              0.682 ** 
##                                                           (0.207)   
## as.factor(id)33:year_month_id                              0.215    
##                                                           (0.108)   
## as.factor(id)34:year_month_id                              0.788 ***
##                                                           (0.189)   
## as.factor(id)35:year_month_id                              0.118    
##                                                           (0.200)   
## as.factor(id)36:year_month_id                              0.655 ***
##                                                           (0.154)   
## as.factor(id)37:year_month_id                             -0.008    
##                                                           (0.173)   
## as.factor(id)38:year_month_id                              0.435 ***
##                                                           (0.092)   
## as.factor(id)39:year_month_id                              0.901 ***
##                                                           (0.138)   
## as.factor(id)40:year_month_id                              0.633 ** 
##                                                           (0.215)   
## as.factor(id)41:year_month_id                              0.567 ***
##                                                           (0.125)   
## as.factor(id)42:year_month_id                              0.331 ** 
##                                                           (0.120)   
## as.factor(id)43:year_month_id                              1.647 ***
##                                                           (0.079)   
## as.factor(id)44:year_month_id                              1.241 ***
##                                                           (0.095)   
## as.factor(id)45:year_month_id                              1.082 ***
##                                                           (0.045)   
## as.factor(id)46:year_month_id                              1.356 ***
##                                                           (0.053)   
## as.factor(id)47:year_month_id                              0.743 ** 
##                                                           (0.262)   
## --------------------------------------------------------------------
## R^2                                                        0.972    
## Adj. R^2                                                   0.968    
## Num. obs.                                               1551        
## RMSE                                                     191.246    
## N Clusters                                                47        
## ====================================================================
## *** p < 0.001; ** p < 0.01; * p < 0.05
# DID estimates and 90% CI
df_estimates <- DID_coefficients_main(DID_results = estimation_results, 
                                         treat_var = "unemploy_shock_diff2",
                                 estimation_label = "yoy_hogo_persons_WLS_trend")

# Event study graph
graph_yoy_hogo_persons_WLS_trend_covar_onlypost <- event_study_graph(data = df_estimates ,
                                          graph_title = "yoy_hogo_persons_WLS_trend")

ggplotly(graph_yoy_hogo_persons_WLS_trend_covar_onlypost)
estimates_yoy_hogo_persons_WLS_trend_covar_onlypost <- df_estimates #for robustness check

results_yoy_hogo_persons_WLS_trend_covar_onlypost <- estimation_results # for only-post DID table

10 Y=PA recipient housholds/生活保護受給世帯

11 Y=PA recipient housholds/生活保護受給世帯 with covar

12 Y=PA recipient housholds(YOY)/生活保護受給世帯(前年同月差)

12.5 WLS, with trends, post-covid-month dummies, Table C.7 (4)

# DID estimation
estimation_results <- dynamic_onlypost_DID_WLS_trend(dataset = df_analysis, 
                    outcome_var = df_analysis$yoy_households_receive, 
                    treat_var = df_analysis$unemploy_shock_diff2)

texreg::screenreg(l = estimation_results , include.ci = FALSE, digits=3)
## 1 coefficient  not defined because the design matrix is rank deficient
## 
## ===========================================
##                                Model 1     
## -------------------------------------------
## treat_var:date_2020_02            2.617 *  
##                                  (1.170)   
## treat_var:date_2020_03            4.578 ** 
##                                  (1.617)   
## treat_var:date_2020_04            6.949 ***
##                                  (1.932)   
## treat_var:date_2020_05            8.989 ***
##                                  (2.406)   
## treat_var:date_2020_06           11.906 ***
##                                  (3.068)   
## treat_var:date_2020_07           11.585 ** 
##                                  (3.400)   
## treat_var:date_2020_08           12.034 ** 
##                                  (3.511)   
## treat_var:date_2020_09           13.119 ** 
##                                  (3.920)   
## as.factor(id)1:year_month_id     -0.535 ***
##                                  (0.143)   
## as.factor(id)2:year_month_id     -0.740 ***
##                                  (0.084)   
## as.factor(id)3:year_month_id     -0.631 ***
##                                  (0.095)   
## as.factor(id)4:year_month_id     -0.689 ***
##                                  (0.112)   
## as.factor(id)5:year_month_id     -0.742 ***
##                                  (0.108)   
## as.factor(id)6:year_month_id     -0.694 ***
##                                  (0.102)   
## as.factor(id)7:year_month_id     -0.977 ***
##                                  (0.097)   
## as.factor(id)8:year_month_id     -0.959 ***
##                                  (0.060)   
## as.factor(id)9:year_month_id     -0.074    
##                                  (0.063)   
## as.factor(id)10:year_month_id    -0.492 ***
##                                  (0.046)   
## as.factor(id)11:year_month_id    -0.506 ***
##                                  (0.131)   
## as.factor(id)12:year_month_id    -0.698 ***
##                                  (0.126)   
## as.factor(id)13:year_month_id    -0.778 ***
##                                  (0.138)   
## as.factor(id)14:year_month_id    -0.535 ** 
##                                  (0.174)   
## as.factor(id)15:year_month_id    -0.699 ***
##                                  (0.079)   
## as.factor(id)16:year_month_id    -0.243 ** 
##                                  (0.087)   
## as.factor(id)17:year_month_id     0.008    
##                                  (0.070)   
## as.factor(id)18:year_month_id     0.030    
##                                  (0.050)   
## as.factor(id)19:year_month_id    -0.693 ***
##                                  (0.075)   
## as.factor(id)20:year_month_id    -0.245 ***
##                                  (0.048)   
## as.factor(id)21:year_month_id    -0.356 ***
##                                  (0.055)   
## as.factor(id)22:year_month_id    -0.101    
##                                  (0.066)   
## as.factor(id)23:year_month_id    -0.105    
##                                  (0.074)   
## as.factor(id)24:year_month_id    -0.004    
##                                  (0.075)   
## as.factor(id)25:year_month_id    -0.183 *  
##                                  (0.069)   
## as.factor(id)26:year_month_id    -0.694 ***
##                                  (0.116)   
## as.factor(id)27:year_month_id    -0.697 ***
##                                  (0.168)   
## as.factor(id)28:year_month_id    -0.721 ***
##                                  (0.131)   
## as.factor(id)29:year_month_id    -1.493 ***
##                                  (0.151)   
## as.factor(id)30:year_month_id    -1.693 ***
##                                  (0.149)   
## as.factor(id)31:year_month_id    -1.031 ***
##                                  (0.099)   
## as.factor(id)32:year_month_id              
##                                            
## as.factor(id)33:year_month_id    -0.491 ***
##                                  (0.070)   
## as.factor(id)34:year_month_id     0.001    
##                                  (0.076)   
## as.factor(id)35:year_month_id    -0.655 ***
##                                  (0.084)   
## as.factor(id)36:year_month_id    -0.098    
##                                  (0.094)   
## as.factor(id)37:year_month_id    -0.679 ***
##                                  (0.089)   
## as.factor(id)38:year_month_id    -0.492 ***
##                                  (0.082)   
## as.factor(id)39:year_month_id    -0.787 ***
##                                  (0.069)   
## as.factor(id)40:year_month_id    -0.154    
##                                  (0.098)   
## as.factor(id)41:year_month_id    -0.183 ***
##                                  (0.019)   
## as.factor(id)42:year_month_id    -0.815 ***
##                                  (0.069)   
## as.factor(id)43:year_month_id     0.290 ***
##                                  (0.070)   
## as.factor(id)44:year_month_id     0.227 *  
##                                  (0.101)   
## as.factor(id)45:year_month_id    -0.006    
##                                  (0.070)   
## as.factor(id)46:year_month_id     0.067    
##                                  (0.113)   
## as.factor(id)47:year_month_id    -0.605 ** 
##                                  (0.182)   
## -------------------------------------------
## R^2                               0.936    
## Adj. R^2                          0.930    
## Num. obs.                      1551        
## RMSE                            166.238    
## N Clusters                       47        
## ===========================================
## *** p < 0.001; ** p < 0.01; * p < 0.05
# DID estimates and 90% CI
df_estimates <- DID_coefficients_main(DID_results = estimation_results, 
                                         treat_var = "unemploy_shock_diff2",
                                 estimation_label = "yoy_hogo_households_WLS_trend")

# Event study graph
graph_yoy_hogo_households_WLS_trend_onlypost <- event_study_graph(data = df_estimates ,
                                          graph_title = "yoy_hogo_households_WLS_trend")

ggplotly(graph_yoy_hogo_households_WLS_trend_onlypost)
estimates_yoy_hogo_households_WLS_trend_onlypost <- df_estimates #for robustness check

results_yoy_hogo_households_WLS_trend_onlypost <- estimation_results # for only-post DID table

13 Y=PA recipient housholds(YOY)/生活保護受給世帯(前年同月差)with covar

13.5 WLS, with trends, post-covid-month dummies, Table C.8 (4)

# DID estimation
estimation_results <- dynamic_onlypost_DID_WLS_trend_covar8Xcovid_months(dataset = df_analysis, 
                    outcome_var = df_analysis$yoy_households_receive, 
                    treat_var = df_analysis$unemploy_shock_diff2)

texreg::screenreg(l = estimation_results , include.ci = FALSE, digits=3)
## 1 coefficient  not defined because the design matrix is rank deficient
## 
## ====================================================================
##                                                         Model 1     
## --------------------------------------------------------------------
## treat_var:date_2020_02                                     1.430    
##                                                           (2.360)   
## treat_var:date_2020_03                                     2.409    
##                                                           (2.699)   
## treat_var:date_2020_04                                     3.086    
##                                                           (3.212)   
## treat_var:date_2020_05                                     3.137    
##                                                           (3.843)   
## treat_var:date_2020_06                                     4.350    
##                                                           (4.403)   
## treat_var:date_2020_07                                     5.710    
##                                                           (4.517)   
## treat_var:date_2020_08                                     4.891    
##                                                           (4.799)   
## treat_var:date_2020_09                                     6.898    
##                                                           (5.283)   
## date_2020_02:google_mobility_index_2020may                 0.168    
##                                                           (0.421)   
## date_2020_03:google_mobility_index_2020may                 0.116    
##                                                           (0.548)   
## date_2020_04:google_mobility_index_2020may                -0.003    
##                                                           (0.611)   
## date_2020_05:google_mobility_index_2020may                -0.344    
##                                                           (0.608)   
## date_2020_06:google_mobility_index_2020may                -0.692    
##                                                           (0.719)   
## date_2020_07:google_mobility_index_2020may                -0.728    
##                                                           (0.718)   
## date_2020_08:google_mobility_index_2020may                -1.104    
##                                                           (0.766)   
## date_2020_09:google_mobility_index_2020may                -1.363    
##                                                           (0.836)   
## date_2020_02:infection_rate_cumulative2020jun              0.305    
##                                                           (0.256)   
## date_2020_03:infection_rate_cumulative2020jun              0.175    
##                                                           (0.306)   
## date_2020_04:infection_rate_cumulative2020jun              0.245    
##                                                           (0.325)   
## date_2020_05:infection_rate_cumulative2020jun              0.135    
##                                                           (0.419)   
## date_2020_06:infection_rate_cumulative2020jun              0.076    
##                                                           (0.454)   
## date_2020_07:infection_rate_cumulative2020jun             -0.012    
##                                                           (0.452)   
## date_2020_08:infection_rate_cumulative2020jun             -0.168    
##                                                           (0.486)   
## date_2020_09:infection_rate_cumulative2020jun             -0.306    
##                                                           (0.466)   
## date_2020_02:death_rate_cumulative2020jun                 -3.141    
##                                                           (2.819)   
## date_2020_03:death_rate_cumulative2020jun                 -2.565    
##                                                           (3.491)   
## date_2020_04:death_rate_cumulative2020jun                 -3.517    
##                                                           (3.683)   
## date_2020_05:death_rate_cumulative2020jun                 -3.505    
##                                                           (4.549)   
## date_2020_06:death_rate_cumulative2020jun                 -3.293    
##                                                           (4.979)   
## date_2020_07:death_rate_cumulative2020jun                 -1.678    
##                                                           (4.967)   
## date_2020_08:death_rate_cumulative2020jun                 -0.549    
##                                                           (5.230)   
## date_2020_09:death_rate_cumulative2020jun                  0.279    
##                                                           (5.115)   
## date_2020_02:Population_per_1_km_2_of_inhabitable_area     0.000    
##                                                           (0.001)   
## date_2020_03:Population_per_1_km_2_of_inhabitable_area     0.001    
##                                                           (0.001)   
## date_2020_04:Population_per_1_km_2_of_inhabitable_area     0.001    
##                                                           (0.001)   
## date_2020_05:Population_per_1_km_2_of_inhabitable_area     0.001    
##                                                           (0.001)   
## date_2020_06:Population_per_1_km_2_of_inhabitable_area     0.001    
##                                                           (0.001)   
## date_2020_07:Population_per_1_km_2_of_inhabitable_area     0.002    
##                                                           (0.001)   
## date_2020_08:Population_per_1_km_2_of_inhabitable_area     0.002    
##                                                           (0.001)   
## date_2020_09:Population_per_1_km_2_of_inhabitable_area     0.001    
##                                                           (0.001)   
## date_2020_02:Secondary_industry_ratio                     74.484 *  
##                                                          (29.061)   
## date_2020_03:Secondary_industry_ratio                     87.534 *  
##                                                          (36.759)   
## date_2020_04:Secondary_industry_ratio                     99.940 *  
##                                                          (40.813)   
## date_2020_05:Secondary_industry_ratio                    121.549 ** 
##                                                          (41.593)   
## date_2020_06:Secondary_industry_ratio                    156.322 ** 
##                                                          (47.883)   
## date_2020_07:Secondary_industry_ratio                    176.026 ***
##                                                          (49.362)   
## date_2020_08:Secondary_industry_ratio                    194.828 ***
##                                                          (53.049)   
## date_2020_09:Secondary_industry_ratio                    215.473 ***
##                                                          (61.003)   
## date_2020_02:Tertiary_industry_ratio                      72.929    
##                                                          (41.907)   
## date_2020_03:Tertiary_industry_ratio                      91.831    
##                                                          (53.496)   
## date_2020_04:Tertiary_industry_ratio                      99.349    
##                                                          (54.390)   
## date_2020_05:Tertiary_industry_ratio                     130.279 *  
##                                                          (64.702)   
## date_2020_06:Tertiary_industry_ratio                     148.711    
##                                                          (74.507)   
## date_2020_07:Tertiary_industry_ratio                     135.716    
##                                                          (74.279)   
## date_2020_08:Tertiary_industry_ratio                     163.492 *  
##                                                          (78.305)   
## date_2020_09:Tertiary_industry_ratio                     168.408 *  
##                                                          (80.176)   
## date_2020_02:Total_population                             -0.001    
##                                                           (0.003)   
## date_2020_03:Total_population                             -0.001    
##                                                           (0.005)   
## date_2020_04:Total_population                              0.002    
##                                                           (0.005)   
## date_2020_05:Total_population                             -0.000    
##                                                           (0.005)   
## date_2020_06:Total_population                              0.004    
##                                                           (0.007)   
## date_2020_07:Total_population                              0.002    
##                                                           (0.007)   
## date_2020_08:Total_population                              0.004    
##                                                           (0.007)   
## date_2020_09:Total_population                              0.007    
##                                                           (0.008)   
## date_2020_02:Ratio_of_aged_population                     -0.036    
##                                                           (0.193)   
## date_2020_03:Ratio_of_aged_population                      0.002    
##                                                           (0.246)   
## date_2020_04:Ratio_of_aged_population                     -0.012    
##                                                           (0.277)   
## date_2020_05:Ratio_of_aged_population                      0.014    
##                                                           (0.294)   
## date_2020_06:Ratio_of_aged_population                      0.185    
##                                                           (0.334)   
## date_2020_07:Ratio_of_aged_population                      0.239    
##                                                           (0.343)   
## date_2020_08:Ratio_of_aged_population                      0.437    
##                                                           (0.363)   
## date_2020_09:Ratio_of_aged_population                      0.633    
##                                                           (0.417)   
## as.factor(id)1:year_month_id                               0.603 ***
##                                                           (0.118)   
## as.factor(id)2:year_month_id                               0.460 ***
##                                                           (0.073)   
## as.factor(id)3:year_month_id                               0.407 ***
##                                                           (0.055)   
## as.factor(id)4:year_month_id                               0.053    
##                                                           (0.126)   
## as.factor(id)5:year_month_id                               0.253 *  
##                                                           (0.113)   
## as.factor(id)6:year_month_id                               0.247    
##                                                           (0.139)   
## as.factor(id)7:year_month_id                              -0.111    
##                                                           (0.120)   
## as.factor(id)8:year_month_id                              -0.214    
##                                                           (0.108)   
## as.factor(id)9:year_month_id                               0.648 ***
##                                                           (0.113)   
## as.factor(id)10:year_month_id                              0.168    
##                                                           (0.149)   
## as.factor(id)11:year_month_id                              0.259 *  
##                                                           (0.111)   
## as.factor(id)12:year_month_id                              0.026    
##                                                           (0.166)   
## as.factor(id)13:year_month_id                             -0.218    
##                                                           (0.132)   
## as.factor(id)14:year_month_id                              0.042    
##                                                           (0.130)   
## as.factor(id)15:year_month_id                              0.022    
##                                                           (0.107)   
## as.factor(id)16:year_month_id                              0.417 *  
##                                                           (0.179)   
## as.factor(id)17:year_month_id                              0.746 ***
##                                                           (0.173)   
## as.factor(id)18:year_month_id                              0.672 ***
##                                                           (0.139)   
## as.factor(id)19:year_month_id                              0.002    
##                                                           (0.157)   
## as.factor(id)20:year_month_id                              0.483 ** 
##                                                           (0.154)   
## as.factor(id)21:year_month_id                              0.178    
##                                                           (0.149)   
## as.factor(id)22:year_month_id                              0.431 ** 
##                                                           (0.155)   
## as.factor(id)23:year_month_id                              0.434 ** 
##                                                           (0.141)   
## as.factor(id)24:year_month_id                              0.615 ***
##                                                           (0.130)   
## as.factor(id)25:year_month_id                              0.429 ** 
##                                                           (0.137)   
## as.factor(id)26:year_month_id                              0.109    
##                                                           (0.153)   
## as.factor(id)27:year_month_id                             -0.045    
##                                                           (0.117)   
## as.factor(id)28:year_month_id                             -0.054    
##                                                           (0.139)   
## as.factor(id)29:year_month_id                             -0.751 ***
##                                                           (0.138)   
## as.factor(id)30:year_month_id                             -0.646 ***
##                                                           (0.113)   
## as.factor(id)31:year_month_id                                       
##                                                                     
## as.factor(id)32:year_month_id                              0.682 ***
##                                                           (0.162)   
## as.factor(id)33:year_month_id                              0.279 ** 
##                                                           (0.081)   
## as.factor(id)34:year_month_id                              0.590 ***
##                                                           (0.143)   
## as.factor(id)35:year_month_id                             -0.003    
##                                                           (0.147)   
## as.factor(id)36:year_month_id                              0.811 ***
##                                                           (0.106)   
## as.factor(id)37:year_month_id                              0.036    
##                                                           (0.123)   
## as.factor(id)38:year_month_id                              0.446 ***
##                                                           (0.064)   
## as.factor(id)39:year_month_id                              0.240 *  
##                                                           (0.094)   
## as.factor(id)40:year_month_id                              0.530 ** 
##                                                           (0.165)   
## as.factor(id)41:year_month_id                              0.623 ***
##                                                           (0.102)   
## as.factor(id)42:year_month_id                              0.054    
##                                                           (0.095)   
## as.factor(id)43:year_month_id                              1.228 ***
##                                                           (0.064)   
## as.factor(id)44:year_month_id                              1.167 ***
##                                                           (0.070)   
## as.factor(id)45:year_month_id                              1.000 ***
##                                                           (0.035)   
## as.factor(id)46:year_month_id                              1.076 ***
##                                                           (0.039)   
## as.factor(id)47:year_month_id                              0.546 ** 
##                                                           (0.191)   
## --------------------------------------------------------------------
## R^2                                                        0.954    
## Adj. R^2                                                   0.948    
## Num. obs.                                               1551        
## RMSE                                                     143.912    
## N Clusters                                                47        
## ====================================================================
## *** p < 0.001; ** p < 0.01; * p < 0.05
# DID estimates and 90% CI
df_estimates <- DID_coefficients_main(DID_results = estimation_results, 
                                         treat_var = "unemploy_shock_diff2",
                                 estimation_label = "yoy_hogo_households_WLS_trend")

# Event study graph
graph_yoy_hogo_households_WLS_trend_covar_onlypost <- event_study_graph(data = df_estimates ,
                                          graph_title = "yoy_hogo_households_WLS_trend")

ggplotly(graph_yoy_hogo_households_WLS_trend_covar_onlypost)
estimates_yoy_hogo_households_WLS_trend_covar_onlypost <- df_estimates #for robustness check

results_yoy_hogo_households_WLS_trend_covar_onlypost <- estimation_results # for only-post DID table

14 Merge results for robustness graphs/アウトカム結果の結合

14.1 Y=PA recipients/生活保護受給者数

#merge and label estimates data
estimates_hogo_persons_bind <- dplyr::bind_rows(estimates_hogo_persons_OLS_notrend, 
                                                estimates_hogo_persons_WLS_notrend, 
                                                estimates_hogo_persons_OLS_trend,
                                                estimates_hogo_persons_WLS_trend)

#change labels and reorder labels
estimates_hogo_persons_bind <- estimates_labeling_poverty(estimates_hogo_persons_bind)

#graph
graph_hogo_persons_bind <- event_study_graph_bind_main(data = estimates_hogo_persons_bind, 
                                             graph_title = "Public Assistance recipients")

ggplotly(graph_hogo_persons_bind)

14.2 Y=PA recipients/生活保護受給者数 with covar

#merge and label estimates data
estimates_hogo_persons_bind_covar <- dplyr::bind_rows(estimates_hogo_persons_OLS_notrend_covar, 
                                                      estimates_hogo_persons_WLS_notrend_covar, 
                                                      estimates_hogo_persons_OLS_trend_covar,
                                                      estimates_hogo_persons_WLS_trend_covar)

#change labels and reorder labels
estimates_hogo_persons_bind_covar <- estimates_labeling_poverty(estimates_hogo_persons_bind_covar)

#graph
graph_hogo_persons_bind_covar <- event_study_graph_bind_main(data = estimates_hogo_persons_bind_covar, 
                                             graph_title = "Public Assistance recipients, with covariates")

ggplotly(graph_hogo_persons_bind_covar)

14.3 Y=PA recipients/生活保護受給者数(対前年度差)

#merge and label estimates data
estimates_yoy_hogo_persons_bind <- dplyr::bind_rows(estimates_yoy_hogo_persons_OLS_notrend, 
                                                    estimates_yoy_hogo_persons_WLS_notrend, 
                                                    estimates_yoy_hogo_persons_OLS_trend,
                                                    estimates_yoy_hogo_persons_WLS_trend)

#change labels and reorder labels
estimates_yoy_hogo_persons_bind <- estimates_labeling_poverty(estimates_yoy_hogo_persons_bind)

#graph
graph_yoy_hogo_persons_bind <- event_study_graph_bind_main(data = estimates_yoy_hogo_persons_bind, 
                                             graph_title = "Public Assistance recipients (year-on-year)")

ggplotly(graph_yoy_hogo_persons_bind)

14.4 Y=PA recipients(YOY)/生活保護受給者数(対前年度差) with covar

#merge and label estimates data
estimates_yoy_hogo_persons_bind_covar <- dplyr::bind_rows(estimates_yoy_hogo_persons_OLS_notrend_covar, 
                                                          estimates_yoy_hogo_persons_WLS_notrend_covar, 
                                                          estimates_yoy_hogo_persons_OLS_trend_covar,
                                                          estimates_yoy_hogo_persons_WLS_trend_covar)

#change labels and reorder labels
estimates_yoy_hogo_persons_bind_covar <- estimates_labeling_poverty(estimates_yoy_hogo_persons_bind_covar)

#graph
graph_yoy_hogo_persons_bind_covar <- event_study_graph_bind_main(data = estimates_yoy_hogo_persons_bind_covar, 
                                             graph_title = "Public Assistance recipients (year-on-year), with covariates")

ggplotly(graph_yoy_hogo_persons_bind_covar)

14.5 Y=PA recipient households/生活保護世帯数

#merge and label estimates data
estimates_hogo_households_bind <- dplyr::bind_rows(estimates_hogo_households_OLS_notrend, 
                                                   estimates_hogo_households_WLS_notrend, 
                                                   estimates_hogo_households_OLS_trend,
                                                   estimates_hogo_households_WLS_trend)

#change labels and reorder labels
estimates_hogo_households_bind <- estimates_labeling_poverty(estimates_hogo_households_bind)

#graph
graph_hogo_households_bind <- event_study_graph_bind_main(data = estimates_hogo_households_bind, 
                                             graph_title = "Public Assistance recipient households")

ggplotly(graph_hogo_households_bind)

14.6 Y=PA recipient households/生活保護世帯数 with covar

#merge and label estimates data
estimates_hogo_households_bind_covar <- dplyr::bind_rows(estimates_hogo_households_OLS_notrend_covar, 
                                                         estimates_hogo_households_WLS_notrend_covar, 
                                                         estimates_hogo_households_OLS_trend_covar,
                                                         estimates_hogo_households_WLS_trend_covar)

#change labels and reorder labels
estimates_hogo_households_bind_covar <- estimates_labeling_poverty(estimates_hogo_households_bind_covar)

#graph
graph_hogo_households_bind_covar <- event_study_graph_bind_main(data = estimates_hogo_households_bind_covar, 
                                             graph_title = "Public Assistance recipient households, with covariates")

ggplotly(graph_hogo_households_bind_covar)

14.7 Y=PA recipient households(YOY)/生活保護世帯数(対前年度差)

#merge and label estimates data
estimates_yoy_hogo_households_bind <- dplyr::bind_rows(estimates_yoy_hogo_households_OLS_notrend, 
                                                       estimates_yoy_hogo_households_WLS_notrend, 
                                                       estimates_yoy_hogo_households_OLS_trend,
                                                       estimates_yoy_hogo_households_WLS_trend)

#change labels and reorder labels
estimates_yoy_hogo_households_bind <- estimates_labeling_poverty(estimates_yoy_hogo_households_bind)

#graph
graph_yoy_hogo_households_bind <- event_study_graph_bind_main(data = estimates_yoy_hogo_households_bind, 
                                             graph_title = "Public Assistance recipient households (year-on-year)")

ggplotly(graph_yoy_hogo_households_bind)

14.8 Y=PA recipient households(YOY)/生活保護世帯数(対前年度差) with covar

#merge and label estimates data
estimates_yoy_hogo_households_bind_covar <- dplyr::bind_rows(estimates_yoy_hogo_households_OLS_notrend_covar, 
                                                             estimates_yoy_hogo_households_WLS_notrend_covar, 
                                                             estimates_yoy_hogo_households_OLS_trend_covar,
                                                             estimates_yoy_hogo_households_WLS_trend_covar)

#change labels and reorder labels
estimates_yoy_hogo_households_bind_covar <- estimates_labeling_poverty(estimates_yoy_hogo_households_bind_covar)

#graph
graph_yoy_hogo_households_bind_covar <- event_study_graph_bind_main(data = estimates_yoy_hogo_households_bind_covar, 
                                             graph_title = "Public Assistance recipient households (year-on-year), with covariates")

ggplotly(graph_yoy_hogo_households_bind_covar)

14.9 GGplotly

ggplotly(graph_hogo_persons_bind)
ggplotly(graph_hogo_persons_bind_covar)
ggplotly(graph_yoy_hogo_persons_bind)
ggplotly(graph_yoy_hogo_persons_bind_covar)
ggplotly(graph_hogo_households_bind)
ggplotly(graph_hogo_households_bind_covar)
ggplotly(graph_yoy_hogo_households_bind)
ggplotly(graph_yoy_hogo_households_bind_covar)

15 Merge graphs/グラフ統合

15.1 Extract legend/legend 取り出し

#Legendの表示

graph_for_legend  <- graph_hogo_persons_bind +
 theme(legend.position = 'bottom', # Adjust x axis label
       legend.title = element_text(color = "black", size = 20),
       legend.text = element_text(color = "black", size = 20))
graph_for_legend  

#extract legend
legend_model_types <- ggpubr::get_legend(graph_for_legend)
legend_model_types <- ggpubr::as_ggplot(legend_model_types)
legend_model_types

15.2 Merge/統合

グラフを統合して論文用に保存。 ### graph size

dpi_num <- 100
width_num <- 15
height_num <- 10

15.2.3 Robustness check

ymin <- - 10
ymax <- 50

ymin_num <- - 10
ymax_num  <- 50
interval <- 10

graph_hogo_persons_bind <- graph_hogo_persons_bind + labs(title = "(a) Public Assistance recipients")+ scale_y_continuous(limit = c(ymin, 100), breaks=seq(ymin_num, 100, interval))

graph_hogo_persons_bind_covar <- graph_hogo_persons_bind_covar + labs(title = "(b) Public Assistance recipients with covariates")+ scale_y_continuous(limit = c(ymin, 100), breaks=seq(ymin_num, 100, interval))

graph_hogo_households_bind <- graph_hogo_households_bind + labs(title = "(c) Public Assistance recipient households")+ scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_hogo_households_bind_covar <- graph_hogo_households_bind_covar + labs(title = "(d) Public Assistance recipient households  with covariates")+ scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))


graph <-  (graph_hogo_persons_bind + graph_hogo_persons_bind_covar) /
  (graph_hogo_households_bind + graph_hogo_households_bind_covar) /
  legend_model_types +
  plot_layout(heights = c(2, 2, 0.5))  #0.3から0.5へ変更 2021Sep7 Waki
 
graph

#保存
ggsave(file = "output/graph_unemploy_diff2_on_PAbenefit_robust.pdf", plot = graph, 
       dpi = dpi_num, width = width_num, height = height_num)     

15.2.4 Robustness check (YOY)

ymin <- - 10
ymax <- 30

ymin_num <- - 10
ymax_num  <- 30
interval <- 10


graph_yoy_hogo_persons_bind <- graph_yoy_hogo_persons_bind + labs(title = "(a) Recipients")+ 
  scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_yoy_hogo_persons_bind_covar <- graph_yoy_hogo_persons_bind_covar + labs(title = "(b) Recipients, with covariates")+ scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_yoy_hogo_households_bind <- graph_yoy_hogo_households_bind + labs(title = "(c) Recipient households ")+ scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_yoy_hogo_households_bind_covar <- graph_yoy_hogo_households_bind_covar + labs(title = "(d) Recipient households, with covariates")+ scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph <-  (graph_yoy_hogo_persons_bind + graph_yoy_hogo_persons_bind_covar) /
  (graph_yoy_hogo_households_bind + graph_yoy_hogo_households_bind_covar) /
  legend_model_types +
  plot_layout(heights = c(2, 2, 0.5))  #0.3から0.5へ変更 2021Sep7 Waki
 
graph

#保存
ggsave(file = "output/graph_unemploy_diff2_on_yoy_PAbenefit_robust.pdf", plot = graph, 
       dpi = dpi_num, width = width_num, height = height_num)

#ggplotly

16 Regression table/回帰結果表 without covar

options("modelsummary_format_numeric_latex" = "plain")

# 列の選択 column order

# 生活保護受給者、生活保護受給世帯、YOYのみ, monthlyhのみ

rows_MONTH <- tribble(~name, ~"(1)", ~"(2)", ~"(3)", ~"(4)",
"Ref. month", "\\footnotesize{Jan.2020}", "\\footnotesize{$\\leq$Jan.2020}",  "\\footnotesize{Jan.2020}", "\\footnotesize{$\\leq$Jan.2020}")

## results list
table_results_MONTH <- list()
table_results_MONTH[["(1)"]] <- results_yoy_hogo_persons_WLS_trend
table_results_MONTH[["(2)"]] <- results_yoy_hogo_persons_WLS_trend_onlypost
table_results_MONTH[["(3)"]] <- results_yoy_hogo_households_WLS_trend
table_results_MONTH[["(4)"]] <- results_yoy_hogo_households_WLS_trend_onlypost


## HTML table
estimates_table_MONTH(df = table_results_MONTH,
                      rows = rows_MONTH,
                      title_words = "Hogo",
                      gof = gm,
                      output_style = "html") %>%
    kableExtra::add_header_above(c(" " = 1, "Recipients" = 2, "Recipient Households" = 2))
## 2 coefficients  not defined because the design matrix is rank deficient
## 1 coefficient  not defined because the design matrix is rank deficient
## 2 coefficients  not defined because the design matrix is rank deficient
## 1 coefficient  not defined because the design matrix is rank deficient
Hogo
Recipients
Recipient Households
Feb. 2020 2.108 2.613 1.259 2.617
(0.835) (1.513) (0.620) (1.170)
Mar. 2020 4.612 5.137 3.171 4.578
(1.393) (1.970) (1.094) (1.617)
Apr. 2020 6.788 7.333 5.491 6.949
(2.041) (2.665) (1.297) (1.932)
May. 2020 9.448 10.014 7.482 8.989
(2.273) (2.913) (1.811) (2.406)
Jun. 2020 13.654 14.241 10.349 11.906
(3.194) (3.869) (2.437) (3.068)
Jul. 2020 13.694 14.301 9.978 11.585
(3.750) (4.369) (2.789) (3.400)
Aug. 2020 14.134 14.761 10.376 12.034
(4.153) (4.760) (2.902) (3.511)
Sep. 2020 15.521 16.169 11.411 13.119
(4.700) (5.262) (3.360) (3.920)
Sample size 1551 1551 1551 1551
R2 Adj. 0.957 0.958 0.930 0.930
Ref. month {Jan.2020} {\(\leq\)Jan.2020} {Jan.2020} {\(\leq\)Jan.2020}
## Latex table
estimates_table_MONTH(df = table_results_MONTH,
                      rows = rows_MONTH,
                      gof = gm,
                      title_words = "Estimation results for Public Assistance, without covariates", 
                      output_style = "latex") %>% 
  kableExtra::add_header_above(c(" " = 1, "Recipients" = 2, "Recipient Households" = 2)) %>%
  kableExtra::add_footnote(c("Notes: Columns (1) and (3) present baseline WLS estimates shown in  the left-hand side of Figure \\ref{fig:DID_unemploy_on_PAbenefit}. Columns (2) and (4) present WLS estimates based on the model \\eqref{eq:did_model_ver2}, weighted by prefecture population size. The treatment variable is the COVID-19-induced employment shock, which is calculated as equation \\eqref{eq:employment_shock}. Robust standard errors are clustered at the prefecture level."),threeparttable = TRUE, notation = "none",escape = FALSE) %>% 
  kableExtra::column_spec(2:7, width = "1.5cm") %>% 
  kableExtra::save_kable("output/table_unemploy_diff2_on_PAbenefit_robust.tex")
## 2 coefficients  not defined because the design matrix is rank deficient
## 
## 1 coefficient  not defined because the design matrix is rank deficient
## 2 coefficients  not defined because the design matrix is rank deficient
## 1 coefficient  not defined because the design matrix is rank deficient

17 Regression table/回帰結果表 with covar

# 列の選択 column order

# 生活保護受給者、生活保護受給世帯、YOYのみ, monthlyhのみ

rows_MONTH <- tribble(~name, ~"(1)", ~"(2)", ~"(3)", ~"(4)",
"Ref. month", "\\footnotesize{Jan.2020}", "\\footnotesize{$\\leq$Jan.2020}",  "\\footnotesize{Jan.2020}", "\\footnotesize{$\\leq$Jan.2020}")

## results list
table_results_MONTH <- list()
table_results_MONTH[["(1)"]] <- results_yoy_hogo_persons_WLS_trend_covar
table_results_MONTH[["(2)"]] <- results_yoy_hogo_persons_WLS_trend_covar_onlypost
table_results_MONTH[["(3)"]] <- results_yoy_hogo_households_WLS_trend_covar
table_results_MONTH[["(4)"]] <- results_yoy_hogo_households_WLS_trend_covar_onlypost


## HTML table
estimates_table_MONTH(df = table_results_MONTH,
                      rows = rows_MONTH,
                      title_words = "Hogo",
                      gof = gm,
                      output_style = "html") %>%
    kableExtra::add_header_above(c(" " = 1, "Recipients" = 2, "Recipient Households" = 2))
## 2 coefficients  not defined because the design matrix is rank deficient
## 1 coefficient  not defined because the design matrix is rank deficient
## 2 coefficients  not defined because the design matrix is rank deficient
## 1 coefficient  not defined because the design matrix is rank deficient
Hogo
Recipients
Recipient Households
Feb. 2020 0.651 1.156 0.069 1.430
(2.259) (2.596) (2.078) (2.360)
Mar. 2020 2.787 3.312 0.998 2.409
(2.787) (3.078) (2.403) (2.699)
Apr. 2020 4.756 5.302 1.625 3.086
(4.151) (4.374) (2.951) (3.212)
May. 2020 4.305 4.872 1.626 3.137
(4.469) (4.639) (3.612) (3.843)
Jun. 2020 6.808 7.395 2.788 4.350
(5.313) (5.526) (4.145) (4.403)
Jul. 2020 9.076 9.683 4.098 5.710
(5.501) (5.718) (4.251) (4.517)
Aug. 2020 8.261 8.889 3.228 4.891
(5.963) (6.118) (4.552) (4.799)
Sep. 2020 11.639 12.288 5.185 6.898
(6.155) (6.300) (5.030) (5.283)
Sample size 1551 1551 1551 1551
R2 Adj. 0.968 0.968 0.947 0.948
Ref. month {Jan.2020} {\(\leq\)Jan.2020} {Jan.2020} {\(\leq\)Jan.2020}
## Latex table
estimates_table_MONTH(df = table_results_MONTH,
                      rows = rows_MONTH,
                      gof = gm,
                      title_words = "Estimation results for Public Assistance, with covariates", 
                      output_style = "latex") %>% 
  kableExtra::add_header_above(c(" " = 1, "Recipients" = 2, "Recipient Households" = 2)) %>%
  kableExtra::add_footnote(c("Notes:  Columns (1) and (3) present WLS estimates shown in the right-hand side of Figure \\ref{fig:DID_unemploy_on_PAbenefit}. Columns (2) and (4) present WLS estimates based on the model \\eqref{eq:did_model_ver2}, weighted by prefecture population size, and eight covariates are additionally controlled for. The treatment variable is the COVID-19-induced employment shock, which is calculated as equation \\eqref{eq:employment_shock}. Robust standard errors are clustered at the prefecture level."),threeparttable = TRUE, notation = "none",escape = FALSE) %>% 
  kableExtra::column_spec(2:7, width = "1.5cm") %>% 
  kableExtra::save_kable("output/table_unemploy_diff2_on_PAbenefit_robust_covar.tex")
## 2 coefficients  not defined because the design matrix is rank deficient
## 
## 1 coefficient  not defined because the design matrix is rank deficient
## 2 coefficients  not defined because the design matrix is rank deficient
## 1 coefficient  not defined because the design matrix is rank deficient